package 蓝桥._2024.回文字符串;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main2 {
    static boolean ishuiwen(String s, int l, int r){
        while (l<r){
            if(s.charAt(l)!=s.charAt(r))
                return false;
            l++;
            r--;
        }
        return true;
    }

    public static void main(String[] args) {
        // System.out.printf("%d %d %d",(int)'l',(int)'q',(int)'b');
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int T = scan.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < T; i++) {
            list.add(scan.next());
        }
        // System.out.println(list);
        for (int i = 0; i < T; i++) {
            String s = list.get(i);

            // 找到字符串从右往左的第一个不是l\q\b的字符
            int r = s.length() - 1;
            while (r >= 0 && (s.charAt(r) == 'l' || s.charAt(r) == 'q' || s.charAt(r) == 'b')) r--;
            int l = 0;
            while(l<=s.length() && (s.charAt(l) == 'l' || s.charAt(l) == 'q' || s.charAt(l) == 'b')) l++;

            if(l>=r){
                System.out.println("Yes");
                break;
            }

            boolean in = ishuiwen(s,l,r);
            boolean out = true;
            while (l>=0&&r<s.length()){
                if(s.charAt(l)!=s.charAt(r)){
                    out = false;
                    break;
                }
                l--;
                r++;
            }
            // 左边的l\b\r未抵消完
            if(l>=0 && r == s.length())
                out = false;
            //
            if( in && out)
                System.out.println("Yes");
            else
                System.out.println("No");
        }

        scan.close();
    }
}